home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / single.asm < prev    next >
Assembly Source File  |  1990-04-07  |  5KB  |  187 lines

  1. *********************************************************************
  2. *
  3. *    Since IEEE Single Precision is apparently not supported in
  4. *    Workbench 1.3, the approach taken here is to convert all
  5. *    single precision quantities to double precision and then use
  6. *    the double precision libraries.
  7. *
  8. *********************************************************************
  9.  
  10.                xref    _MathIeeeDoubBasBase
  11.  
  12.                xref    .Fs2d
  13.                xref    .Fd2s
  14.                xref    .Fd2l
  15.                xref    .Fl2d
  16.                xref    .FDopen
  17.  
  18. bias           SET    -30
  19.  
  20. libref         MACRO
  21. _LVO\1         EQU    bias
  22. bias           SET    bias-6
  23.                ENDM
  24.  
  25. *------------------------------------------------------------------
  26. * Note: In order to generate the correct biases, these *Must* be in the
  27. * same order as the mathieeedoubbas_lib.fd file.
  28. *------------------------------------------------------------------
  29.  
  30.                libref    IEEEDPFix
  31.                libref    IEEEDPFlt
  32.                libref    IEEEDPCmp
  33.                libref    IEEEDPTst
  34.                libref    IEEEDPAbs
  35.                libref    IEEEDPNeg
  36.                libref    IEEEDPAdd
  37.                libref    IEEEDPSub
  38.                libref    IEEEDPMul
  39.                libref    IEEEDPDiv
  40.                libref    IEEEDPFloor    ; needs release 1.2+
  41.                libref    IEEEDPCeil    ; needs release 1.2+
  42.  
  43. *********************************************************************
  44. *
  45.            SECTION Single,CODE
  46.  
  47. *-------------------------------------------------------------------
  48. * Do a one parameter MathIeeeDouble function with SP arguments
  49. *-------------------------------------------------------------------
  50. .FSdo1:
  51.     tst.l    _MathIeeeDoubBasBase
  52.     bne.s    1$
  53.     jsr    .FDopen
  54. 1$:
  55.     movem.l    A6,-(A7)
  56.     move.l    _MathIeeeDoubBasBase,A6    
  57.     add.l    4(A7),A6
  58.         jsr     .Fs2d
  59.     jsr    (A6)
  60.         jsr     .Fd2s
  61.     movem.l    (A7)+,A6
  62.     addq    #4,A7        ; unstack the function offset.
  63.     rts
  64.  
  65. *-------------------------------------------------------------------
  66. * Do a two parameter MathIeeeDouble function with SP arguments
  67. *-------------------------------------------------------------------
  68. .FSdo2
  69.     tst.l    _MathIeeeDoubBasBase
  70.     bne.s    1$
  71.     jsr    .FDopen
  72. 1$:
  73.     movem.l    D2-D4/A6,-(A7)
  74.     move.l    _MathIeeeDoubBasBase,A6    
  75.     add.l    16(A7),A6
  76.         move.l  d0,d4
  77.         move.l  d1,d0
  78.         jsr     .Fs2d
  79.         move.l  d0,d2
  80.         move.l  d1,d3
  81.         move.l  d4,d0
  82.         jsr     .Fs2d
  83.     jsr    (A6)
  84.         jsr     .Fd2s
  85.     movem.l    (A7)+,D2-D4/A6
  86.     addq    #4,A7        ; Unstack the function offset.
  87.     rts
  88.  
  89. *********************************************************************
  90. *
  91. *    Single multiply arguments are in D0,D1
  92. *
  93.            XDEF    .FSmul
  94. .FSmul:
  95.                pea    _LVOIEEEDPMul
  96.                jmp     .FSdo2
  97.  
  98. *********************************************************************
  99. *
  100. *    Single divide arguments are in D0,D1
  101. *
  102.            XDEF    .FSdiv
  103. .FSdiv:
  104.                pea    _LVOIEEEDPDiv
  105.                jmp     .FSdo2
  106.  
  107. *********************************************************************
  108. *
  109. *    Single add arguments are in D0,D1
  110. *
  111.            XDEF    .FSadd
  112. .FSadd:
  113.                pea    _LVOIEEEDPAdd
  114.                jmp     .FSdo2
  115.  
  116. *********************************************************************
  117. *
  118. *    Single subtract arguments are in D0,D1
  119. *
  120.            XDEF    .FSsub
  121. .FSsub:
  122.                pea    _LVOIEEEDPSub
  123.                jmp     .FSdo2
  124.  
  125. *********************************************************************
  126. *
  127. *    Single negate argument is in D0
  128. *
  129.            XDEF    .FSneg
  130. .FSneg:
  131.                pea    _LVOIEEEDPNeg
  132.                jmp     .FSdo1
  133.  
  134. *********************************************************************
  135. *
  136. *    Single compare arguments are in D0,D1
  137. *
  138.            XDEF    .FScmp
  139. .FScmp:
  140.                tst.l    _MathIeeeDoubBasBase
  141.                bne.s    1$
  142.                jsr    .FDopen
  143. 1$:
  144.                movem.l    D2-D4/A6,-(A7)
  145.                move.l  d0,d4
  146.                move.l  d1,d0
  147.                jsr     .Fs2d
  148.                move.l  d0,d2
  149.                move.l  d1,d3
  150.                move.l  d4,d0
  151.                jsr     .Fs2d
  152.                move.l    _MathIeeeDoubBasBase,A6    
  153.                jsr     _LVOIEEEDPCmp(A6)
  154.                movem.l    (A7)+,D2-D4/A6
  155.            tst.l   D0
  156.            bne.s   Lcmps1
  157.            move.l  #0,D0
  158.            bra.s   Lcmps3
  159. Lcmps1
  160.            bmi.s   Lcmps2
  161.            move.l  #1,D0
  162.            bra.s   Lcmps3
  163. Lcmps2
  164.            move.l  #-1,D0
  165. Lcmps3
  166.            rts               ; return to caller
  167.  
  168. *********************************************************************
  169. *
  170. *    Convert long to single : Input in D0
  171. *
  172.     XDEF    .Fl2s
  173. .Fl2s:
  174.                jsr .Fl2d
  175.                jmp .Fd2s
  176.  
  177. *********************************************************************
  178. *
  179. *    Convert single to long : Input in D0
  180. *
  181.     XDEF    .Fd2l
  182. .Fs2l:
  183.                jsr .Fs2d
  184.                jmp .Fd2l
  185.  
  186.            END
  187.